package com.solocredit.finance.weight.pickerview.adapter;


import com.solocredit.finance.base.BaseApplication;
import com.solocredit.finance.R;
import com.solocredit.finance.weight.wheelview.adapter.WheelAdapter;

/**
 * Numeric Wheel adapter.
 */
public class MonthWheelAdapter implements WheelAdapter {

	private Integer[] MONTH = {
			R.string.month1,R.string.month2,R.string.month3,R.string.month4,
			R.string.month5,R.string.month6,R.string.month7,R.string.month8,
			R.string.month9,R.string.month10,R.string.month11,R.string.month12,
	};

	private int minValue;
	private int maxValue;

	/**
	 * Constructor
	 * @param minValue the wheel min value
	 * @param maxValue the wheel max value
	 */
	public MonthWheelAdapter(int minValue, int maxValue) {
		this.minValue = minValue;
		this.maxValue = maxValue;
	}

	@Override
	public Object getItem(int index) {
		if (index >= 0 && index < getItemsCount()) {
			int value = minValue + index;
//			return value;
			return BaseApplication.application.getString(MONTH[value - 1]);
		}
		return 0;
	}

	@Override
	public int getItemsCount() {
		return maxValue - minValue + 1;
	}
	
	@Override
	public int indexOf(Object o){
		try {
			return (int)o - minValue;
		} catch (Exception e) {
			return -1;
		}

	}
}
